﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;

public class ResourceSpawner : MonoBehaviour
{

    private float x;
    private float y;
    private float times = 0;

    public GameObject monsterPre;
    public GameObject monsteParent;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (GameStateManager.GameState == GameState.Playing)
        {
            times += Time.deltaTime;
            if (times >= 0.3)
            {
                times = 0;
                x = Random.Range(-760, 760); //来不及了，直接写死
                y = Random.Range(-345, 345);
                if (x >= 0)
                {
                    GameObject monsterNode2 = Instantiate(monsterPre, new Vector3(x, y, 0), new Quaternion(0,-180,0,0));
                    monsterNode2.transform.parent = monsteParent.transform;
                }
                else
                {
                    GameObject monsterNode1 = Instantiate(monsterPre, new Vector3(x, y, 0), Quaternion.identity);
                    monsterNode1.transform.parent = monsteParent.transform;
                }
           
            } 
        }
    }
}
